<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>我的考试</title>
    <link rel="stylesheet" href="/lims/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lims/css/common.css">
    <link rel="stylesheet" href="/lims/css/eleTree.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css">
    <script src="/lims/layui/layui.js"></script>
    <script type="text/javascript" src="/lims/layui/global.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/ajaxupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lims/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/lay/dest/layui.all.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <style>
        html, body {
            width: 99%;
            height: 99%;
        }

        .layui-tab {
            height: 98%;
        }

        .layui-tab-content {
            height: calc(100% - 50px)
        }

        .layui-tab-item, .layui-card {
            height: 100%;
        }
    </style>

</head>
<body style="background-color: white;padding: 5px">
<div class="layui-tab" lay-filter="tab">
    <ul class="layui-tab-title">
        <li test-type="0" class="layui-this">课程考试</li>
        <li test-type="1" >阶段考试</li>
    </ul>
    <div class="layui-tab-content">

        <div class="layui-tab-item layui-show">

        <table id="Settlement1" lay-filter="SettlementFilter1"></table>

        </div>

    </div>
</div>

<%--  ExamType参数说明 0可以考试 1已经考试完毕 2截止时间到 3补考 4还未学习完毕不允许考试  --%>

<script type="text/html" id="barOperation">

    {{# if (d.examType ==0){ }}
    <a class="layui-btn layui-btn-xs" style="font-size: 12px"  lay-event="exam" id="exam">考试</a>
    {{#  } else if(d.examType ==1){ }}
    <a class="layui-btn layui-btn-xs layui-bg-orange" style="font-size: 12px" lay-event="grade" id="grade">查看成绩</a>
    {{#  } else if(d.examType ==2){ }}
    <span style="color:red;font-size: 12px" >考试已截止</span>
    {{#  } else if(d.examType ==3){ }}
    <a class="layui-btn layui-btn-xs"  lay-event="exam2" style="font-size: 12px" id="exam2">补考</a>
    {{#  } else if(d.examType ==4){ }}
    <span style="color:red;font-size: 12px">还未学习完毕</span>
    {{#  } }}



</script>
<script type="text/javascript">
    layui.use('element', function () {
        var $ = layui.jquery
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        //触发事件
        var active = {
            tabAdd: function () {
                //新增一个Tab项
                element.tabAdd('demo', {
                    title: '新选项' + (Math.random() * 1000 | 0) //用于演示
                    , content: '内容' + (Math.random() * 1000 | 0)
                    , id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                })
            }
            , tabDelete: function (othis) {
                //删除指定Tab项
                element.tabDelete('demo', '44'); //删除：“商品管理”


                othis.addClass('layui-btn-disabled');
            }
            , tabChange: function () {
                //切换到指定Tab项
                element.tabChange('demo', '22'); //切换到：用户管理
            }
        };

        $('.site-demo-active').on('click', function () {
            var othis = $(this), type = othis.data('type');
            active[type] ? active[type].call(this, othis) : '';
        });

        //Hash地址的定位
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

        element.on('tab(test)', function (elem) {
            location.hash = 'test=' + $(this).attr('lay-id');
        });

    });
    var first;
    var sencond;
    layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            , layer = layui.layer //弹层
            , table = layui.table //表格
            , carousel = layui.carousel //轮播
            , upload = layui.upload //上传
            , element = layui.element //元素操作
            , slider = layui.slider //滑块
        //执行一个 table 实例
        table1 = table.render({
            elem: '#Settlement1'
            , url: '/exaExamination/selectQuestion' //数据接口
            , title: '报名信息表'
            ,where: { //设定异步数据接口的额外参数，任意设
                testType: 0 // 0是课程考试 1是阶段考试
            }
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'signupId', title: 'ID', sort: true, fixed: 'left', hide: true}
                , {field: 'pName', title: '试卷名称',}
                , {field: 'status', title: '发布状态',templet:function(d){
                        if(d.status==0){
                            return '未发布'
                        }else{
                            return '已发布'
                        }
                    }}
                , {field: 'courseName', title: ' 课程'}
                , {field: 'courseStageName', title: '课程阶段'}
                , {field: 'countScores', title: '总分'}
                ,{fixed: 'right',width:200, title: '操作',align:'center', toolbar: '#barOperation'}
            ]]
        });
        table.on('tool(SettlementFilter1)', function(obj){//注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var signupId= data.signupId;
            var urlTitle='/course';
            var scoreId = obj.data.scoreId;
            if(scoreId==undefined){
                scoreId = ''
            }
            var dateNow = new Date();
            if(layEvent === 'exam'){
                window.open("/tbExamList/examination?dateNow="+dateNow.getTime()+'&pId='+obj.data.pId+"&scoreId="+scoreId)
            }else if(layEvent === 'grade'){
                window.open("/tbExamList/testPaperExa?pId="+obj.data.pId+"&scoreId="+scoreId)
            }else if(layEvent === 'exam2'){
                window.open("/tbExamList/examination?dateNow="+dateNow.getTime()+'&pId='+obj.data.pId+"&scoreId="+scoreId)
            }
        });

        element.on('tab(tab)', function(data){
            // 判断是哪个标签被点击
            var index = data.index;
            // 表格数据重新加载
            table1.reload({
                where: { //设定异步数据接口的额外参数，任意设
                    testType: index // 0是课程考试 1是阶段考试
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            })
        });

    });


</script>

</body>


</html>